<template>
	<view>
		<!-- 手机状态栏高度 -->
		<view class="dhl"></view>
		<!-- 顶部背景 -->
		<view class="top_bg">
			<image src="../../static/mine/topbg.png" mode="aspectFill"></image>
		</view>
		<view class="content dis_f_co">
			<image class="sz_btn" src="../../static/mine/szbtn.png" @click="go_sz"></image>
			<view style="padding: 0 24rpx;">
				<!-- 顶部头像部分 -->
				<view class="dis_f_l_c" style="width: 100%;margin-bottom: 36rpx;">
					<image class="tx" :src="user.avatar" mode=""></image>
					<view class="dis_f_co" style="width: calc(100% - 120rpx);">
						<view class="username font_bold">{{user.name}}</view>
						<view class="dis_f_sb_b" style="width: 100%;">
							<view class="dis_f_l_c">
								<image v-if="user.isvip" class="hy_logo" src="../../static/mine/hy.png" mode=""></image>
								<view v-if="user.isvip" class="hy_vip">{{user.vipname}}</view>
								<view v-else class="hy_pt">{{user.vipname}}</view>
								<view v-if="user.level" class="hy_vip" style="margin-left: 10rpx;">{{user.levelname}}</view>
							</view>
							<view class="dis_f_l_c zy_btn" @click="go_grzy">
								<view class="title">个人主页</view>
								<image src="../../static/mine/back.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
				<!-- 数字部分 -->
				<view class="num dis_f_sb_c">
					<view class="dis_f_co_c_c" @click="go_td">
						<view class="title">{{user.team}}</view>
						<view class="b_text">团队</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_sy(1)">
						<view class="title">{{user.moremoney}}</view>
						<view class="b_text">总收益</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_sy(2)">
						<view class="title">{{user.todymoney}}</view>
						<view class="b_text">当日收益</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_qb">
						<view class="title">{{user.money}}</view>
						<view class="b_text">可提现</view>
					</view>
				</view>
				<!-- 顶部按钮 -->
				<view class="top_btn dis_f_sb_c">
					<view class="dis_f_co_c_c" @click="go_qb">
						<image src="../../static/mine/btn1_1.png" mode=""></image>
						<view>我的钱包</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_vip">
						<image src="../../static/mine/btn1_2.png" mode=""></image>
						<view>开通VIP</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_hb">
						<image src="../../static/mine/btn1_3.png" mode=""></image>
						<view>红包记录</view>
					</view>
					<view class="dis_f_co_c_c" @click="go_help">
						<image src="../../static/mine/btn1_4.png" mode=""></image>
						<view>帮助中心</view>
					</view>
				</view>
				<!-- 底部按钮 -->
				<view class="bottom_btn dis_f_co">
					<view class="title">常用工具</view>
					<view class="dis_f_sb_c btns" style="padding: 0 60rpx;margin-bottom: 40rpx;">
						<view class="dis_f_co_c_c" @click="go_fb">
							<image src="../../static/mine/btn2_1.png" mode=""></image>
							<view class="dis_f_c_c">人脉管理</view>
						</view>
						<view class="dis_f_co_c_c" @click="go_gl">
							<image src="../../static/mine/btn2_2.png" mode=""></image>
							<view class="dis_f_c_c">管理广告</view>
						</view>
						<view class="dis_f_co_c_c" @click="xs_jd_gl">
							<image src="../../static/mine/btn2_3.png" mode=""></image>
							<view class="dis_f_c_c">任务管理</view>
						</view>
						<view class="dis_f_co_c_c" @click="xs_gl">
							<image src="../../static/mine/btn2_4.png" mode=""></image>
							<view class="dis_f_c_c">悬赏管理</view>
						</view>
					</view>
					<view class="dis_f_sb_c btns" style="padding: 0 60rpx;">
						<view class="dis_f_co_c_c" @click="go_dtgl">
							<image src="../../static/mine/btn2_5.png" mode=""></image>
							<view class="dis_f_c_c">动态管理</view>
						</view>
						<view class="dis_f_co_c_c" @click="go_td">
							<image src="../../static/mine/btn2_6.png" mode=""></image>
							<view class="dis_f_c_c">我的团队</view>
						</view>
						<view class="dis_f_co_c_c" @click="go_yq(0)">
							<image src="../../static/mine/btn2_7.png" mode=""></image>
							<view class="dis_f_c_c">邀请领收益</view>
						</view>
						
						<view class="dis_f_co_c_c" @click="go_hhr">
							<image src="../../static/mine/btn2_8.png" mode=""></image>
							<view class="dis_f_c_c">开通合伙人</view>
						</view>
					</view>
					
				</view>
			</view>
			
			
			<!-- 顶部公告 -->
			<view class="g_g2 dis_f_c_c">
				<image src="../../static/mine/mine2.jpg" mode=""></image>
			</view>
			<view class="g_g dis_f_c_c" style="margin-bottom: 100rpx;">
				<view class="gg_title">本平台杜绝一切刷号嫌疑,一经发现终身封号处理!</view>
			</view>
			<!-- 客服 -->
			<view class="kf_btn dis_f_co_c_c" @click="startChat">
				<image src="../../static/mine/kf.png" mode=""></image>
				<view style="font-size: 22rpx;">在线客服</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as bytedesk from '@/components/bytedesk_kefu/js/api/bytedesk.js'
	export default {
		data() {
			return {
				hy_level:true,
				user:[],
				workGroupWid:'202109171434083',
			};
		},
		onLoad() {
			let subDomain = '202109291301332ba405b3572d842158fba465e5c507646'
			// 登录后台->渠道管理-》uniapp中创建应用获取
			let appKey = 'a4aa6f66-dc0b-464c-a427-9fc3ecbf6cef'
			bytedesk.init(subDomain, appKey);
			this.$.ajax(1, 'post', 'index/getuser', {
				uid:uni.getStorageSync('uid'),
				token:uni.getStorageSync('token')
			}, (res) => {
				console.log(res)
				if(res.code == 1){
				this.user = res.userinfo
				}
				
			})
			},
			onShow() {
				
				this.$.ajax(1, 'post', 'index/getuser', {
					uid:uni.getStorageSync('uid'),
					token:uni.getStorageSync('token')
				}, (res) => {
					console.log(res)
					if(res.code == 1){
					this.user = res.userinfo
					if(uni.getStorageSync('salt') == '' || uni.getStorageSync('salt') != this.user.salt)
					uni.setStorageSync('salt',this.user.salt)
					}
					
				})
			},
		methods:{
			startChat () {
			  // console.log('start chat')
			  uni.navigateTo({
				  
			    url: '../../components/bytedesk_kefu/chat-kf?wid=' + this.workGroupWid + '&type=workGroup&aid=&title=萝卜丝'
			  });
			},
			go_sy(e){
				this.$.open('/pages/mine/shou_yi?type='+e)
			},
			go_td(){
				this.$.open('/pages/mine/wd_td')
			},
			go_qb(){
				this.$.open('/pages/mine/wallet')
			},
			go_vip(){
				this.$.open('/pages/mine/kt_vip')
			},
			go_hb(){
				this.$.open('/pages/mine/hb_jl')
			},
			go_fb(){
				this.$.open('/pages/ren_mai/rm_gl')
			},
			go_gl(){
				this.$.open('/pages/guang_gao/gg_gl')
			},
			go_help(){
				this.$.open('/pages/mine/help')
			},
			go_sz(){
				this.$.open('/pages/mine/she_zhi')
			},
			go_hhr(){
				this.$.open('/pages/mine/hhr')
			},
			go_yq(){
					this.$.open('/pages/mine/yq_lsy')
			},
			go_yq1(){
				this.$.open('/pages/mine/yq_lsy1')
			},
			go_grzy(){
				this.$.open('/pages/mine/gr_zy?uid='+this.user.id)
			},
			go_login(){
				this.$.open('/pages/login/login')
			},
			go_dtgl(){
				this.$.open('/pages/guang_chang/dt_gl')
			},
			xs_jd_gl(){
				this.$.open('/pages/xuan_shang/xs_jd_gl')
			},
			xs_gl(){
				this.$.open('/pages/xuan_shang/xs_gl')
			},
		},
		onPullDownRefresh(){
			// this.list = []
			this.$.ajax(1, 'post', 'index/getuser', {
				uid:uni.getStorageSync('uid'),
				token:uni.getStorageSync('token')
			}, (res) => {
				console.log(res)
				if(res.code == 1){
				this.user = res.userinfo
				if(uni.getStorageSync('salt') == '' || uni.getStorageSync('salt') != this.user.salt)
				uni.setStorageSync('salt',this.user.salt)
				}
				
			})
			setTimeout(function () {
			            uni.stopPullDownRefresh();
			}, 1000);
		},
	}
</script>

<style lang="scss">
	
	.kf_btn{
		
		position: fixed;
		top: 600rpx;
		right: 24rpx;
		image{
			width: 80rpx;
			height: 80rpx;
		}
	}
	// 顶部背景图
	.top_bg {
		position: fixed;
		width: 100%;
		height: calc(508rpx + var(--status-bar-height));
		z-index: 1;
	
		image {
			width: 100%;
			height: 100%;
		}
	}
	.content{
		position: fixed;
		width: 100%;
		top: calc(var(--status-bar-height) + 128rpx);
		
		// bottom: 120rpx;
		// left: 0;
		z-index: 2;
		.sz_btn{
			width: 40.58rpx;
			height: 36.62rpx;
			position: fixed;
			top:66rpx; 
			right: 48rpx;
		}
		.tx{
			width: 106rpx;
			height: 106rpx;
			border-radius: 50%;
			margin-right: 24rpx;
		}
		.username{
			font-size: 34rpx;
			color: #fff;
			line-height: 48rpx;
			margin-bottom: 10rpx;
		}
		.hy_logo{
			width: 36.29rpx;
			height: 28.88rpx;
			margin-right: 6rpx;
		}
		.hy_vip{
			font-size: 22rpx;
			line-height: 32rpx;
			color: #CA9A5A;
		}
		.hy_pt{
			font-size: 22rpx;
			line-height: 32rpx;
			color: #fff;
		}
		.zy_btn{
			.title{
				font-size: 26rpx;
				line-height: 36rpx;
				color: #fff;
				margin-right: 12rpx;
			}
			image{
				width: 12.02rpx;
				height: 20.31rpx;
			}
		}
		.num{
			width: 100%;
			padding: 0 24rpx;
			color: #fff;
			margin-bottom: 48rpx;
			.title{
				font-size: 32rpx;
				line-height: 48rpx;
			}
			.b_text{
				font-size: 22rpx;
				line-height: 32rpx;
			}
		}
		.top_btn{
			width: 100%;
			padding: 36rpx 58rpx;
			margin-bottom: 24rpx;
			background-color: #fff;
			font-size: 22rpx;
			line-height: 32rpx;
			box-shadow: 0rpx 6rpx 24rpx rgba(34, 34, 34, 0.05);
			border-radius: 20rpx;
			image{
				width: 49.95rpx;
				height: 49.94rpx;
				margin-bottom: 12rpx;
			}
		}
		.bottom_btn{
			width: 100%;
			background-color: #fff;
			font-size: 22rpx;
			color: #222222;
			line-height: 32rpx;
			box-shadow: 0rpx 6rpx 24rpx rgba(34, 34, 34, 0.05);
			border-radius: 20rpx;
			padding: 36rpx 0 36rpx 22rpx;
			margin-bottom: 20rpx;
			.btns{
				view{
					width: 120rpx;
				}
			}
			.title{
				font-size: 28rpx;
				line-height: 40rpx;
				margin-bottom: 40rpx;
			}
			image{
				width: 42rpx;
				height: 42rpx;
				margin-bottom: 14rpx;
			}
		}
		.g_g{
			width: 100%;
			height: 166rpx;
			background-image: url(../../static/mine/gg.png);
			background-size:100% 100%;
			.gg_title{
				font-size: 30rpx;
				line-height: 34rpx;
				color: #777777;
				
			}
		}
		.g_g2{
			width: 100%;
			height: 166rpx;
			padding: 0 24rpx;
			
			// border-radius: 20rpx;
			image{
				
				width: 100%;
				height: 100%;
				border-radius: 20rpx;
			}
		}
	}
</style>
